//
//  ZQIconView.m
//  柳州微博
//
//  Created by Apple_Lzzy45 on 16/11/3.
//  Copyright © 2016年 Apple_Lzzy40. All rights reserved.
//

#import "ZQIconView.h"
#import "ZQUser.h"

@interface ZQIconView ()
@property(nonatomic,strong) UIImageView *verifiedView;

@end

@implementation ZQIconView
-(UIImageView *)verifiedView
{
    if (_verifiedView == nil) {
        _verifiedView =[[UIImageView alloc]init];
        [self addSubview:_verifiedView];
    }
    return _verifiedView;
}
-(void)setUser:(ZQUser *)user
{
    _user =user;
    
    
    //下载头像图片
      [self sd_setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:[UIImage imageNamed:@"avatar_default_small"]];
    
    //下载加v图片
    //判断是否是v认证
    switch (user.verified_type) {
        case ZQUserVerifiedTypePersonal:
            self.verifiedView.hidden = NO;
            self.verifiedView.image =[UIImage imageNamed:@"avatar_vip"];
            break;
            //企业、媒体、网站的认证
        case ZQUserVerifiedTypeEnterprice:
        case ZQUserVerifiedTypeOrgMedia:
        case ZQUserVerifiedTypeOrgWebsite:
            self.verifiedView.hidden = NO;
            self.verifiedView.image =[UIImage imageNamed:@"avatar_enterprise_vip"];
            break;
            
            //微博达人
        case ZQUserVerifiedTypeDaren:
            self.verifiedView.hidden = NO;
            self.verifiedView.image =[UIImage imageNamed:@"avatar_grassroot"];
            
        default:  //没有认证 则隐藏
            self.verifiedView.hidden = YES;
            break;
    }
    self.verifiedView.image =[UIImage imageNamed:@"avatar_vip"];
    
 }
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.verifiedView.size =self.verifiedView.image.size;
    self.verifiedView.x=self.width - self.verifiedView.width * 0.8;
    self.verifiedView.y=self.height - self.verifiedView.height *0.8;
//    self.layer.cornerRadius = self.width/2;
//    self.layer.masksToBounds = YES;
}
-(void)dealloc
{

    NSLog(@"我没了！");
}
@end
